import React, { Component } from "react";
import { BrowserRouter as Router, Route, Navigate, Routes } from "react-router-dom";
import Home from "./page/home";
import olMap from "./utils/olMap";
// RequireAuth 组件相当于一个拦截器，是否返回被拦截的组件要听他的
function RequireAuth({ children }: any) {
	const authed = localStorage.getItem('token') ? true : false
	return authed ? ( // 判断 localstorage 中登录状态是否为 true
		children
	) : (
		<Navigate to="/" /> // 跳转到登录
	);
}

export default class router extends Component {

	render() {
		return (
			<>
				<Router>
					<Routes>
						<Route path={`/`} element={<Home />} />
						{/* <RequireAuth> */}
						{/* </RequireAuth> */}
					</Routes>
				</Router >
			</>
		)
	}
}
